//
//  YSVoucherCell.m
//  Yueshi
//
//  Created by Northwan on 15/9/24.
//  Copyright © 2015年 悦食中国. All rights reserved.
//

#import "YSVoucherCell.h"
@interface YSVoucherCell()
@property (weak, nonatomic) IBOutlet UILabel *amountLabel;
@property (weak, nonatomic) IBOutlet UILabel *useConditionLabel;
@property (weak, nonatomic) IBOutlet UILabel *effactiveTimeLabel;
@property (weak, nonatomic) IBOutlet UILabel *statusLabel;
@property (weak, nonatomic) IBOutlet UIImageView *topStatusView;

@end


@implementation YSVoucherCell

+(instancetype)cellWithTableView:(UITableView *)tableview{
    static NSString *CellIdentiferId = @"YSVoucherCell";
    YSVoucherCell *cell =  [tableview dequeueReusableCellWithIdentifier:CellIdentiferId];
    return cell;
}

-(void)setVoucher:(YSVoucher *)voucher{
    _voucher = voucher;
    
    [self.amountLabel setText:[NSString stringWithFormat:@"%ld",voucher.amount]];
    [self.useConditionLabel setText:voucher.useCondition];
    [self.effactiveTimeLabel setText:[NSString stringWithFormat:@"有效期至%@",voucher.effactiveTime]];
    if(voucher.isPast){//已过期
        [self.statusLabel setText:@"已过期"];
        [_topStatusView  setImage:IMG(@"bg_voucher_gray")];
    }else{//未过期
        [_topStatusView  setImage:IMG(@"bg_voucher_red")];
        [self.statusLabel setText:@"未使用"];
    }
}

@end
